/**
 * Created by Administrator on 2017/10/30.
 */
import React from 'react'
import { Grid } from 'antd-mobile';
import './FineRecommended.css'
import  FineRecommendedTitle from './img/title.png'
import  goodsLogo from './img/goods.png'
import  Home_integral from '../../../../static/img/Home_integral.png'
import sell_11 from  './img/11.11icon.png'
import  more from  './img/more.png'

const data = Array.from(new Array(3)).map((_val, i) => ({
    icon: goodsLogo
}));

class FineRecommended extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            FineRecommended:[],
            product_href:'productinfo.php?product_id='
        };
    }
    componentWillReceiveProps(nextProps){
        if(nextProps.FineRecommended.length>1){
            this.setState({
                FineRecommended: nextProps.FineRecommended,
            });

        }
    }
    go_to_product_info(product_id){
        window.location.href=this.state.product_href+product_id
    }
    render(){
        return (
            <div>
                <div className="FineRecommendedTitle">
                    <div className="FineRecommendedTitle_img">
                        <img src={FineRecommendedTitle} alt=""/>
                    </div>
                    <div className="FineRecommendedTitle_more"
                     onClick={()=>window.location.href="class_lis.php?title=精品推荐&class_id="+this.props.FineRecommended_class_id}
                    >
                        <img  src={more}/>
                    </div>
                </div>
                {this.state.FineRecommended?
                    <div>
                        {this.state.FineRecommended.map(item => (
                            <div className="FineRecommended_item"
                                 onClick={ ()=>{this.go_to_product_info(item.product_id) } }
                            >

                                <div className="FineRecommended_item_left">
                                        <img src={item.image}/>
                                </div>
                                <div className="FineRecommended_item_right">
                                        <div className="FineRecommended_item_sell_title">
                                            <img src={sell_11} /> {item.product_name}
                                        </div>
                                        <div className="FineRecommended_item_sell_info">
                                            <div className="FineRecommended_item_sell_info_price">￥{item.sku[0].price}</div>
                                            <div className="FineRecommended_item_sell_info_num"
                                              style={{
                                                  color:'#A7A9AA'
                                              }}
                                            >月销{item.sku[0].sell_stock}</div>
                                        </div>
                                        <div className="FineRecommended_item_sell_discounts">
                                            <div className="FineRecommended_vipPrice" >VIP：￥{item.sku[0].vip_price}</div>
                                            <div className="FineRecommended_sendIntegral">
                                                <img src={Home_integral}/>积分{item.sku[0].deduction}
                                            </div>
                                        </div>
                                </div>

                            </div>
                        ))}
                    </div>
                    :''
                }

            </div>
        )
    }

}


export default FineRecommended